<?php

class PasswordForm extends CFormModel
{
	public $old_password;
	public $new_password_confirm;
	public $new_password;

	/**
	 * Declares the validation rules.
	 * The rules state that username and password are required,
	 * and password needs to be authenticated.
	 */
	public function rules()
	{
		return array(
			array('old_password, new_password_confirm, new_password', 'required'),
			array('old_password, new_password_confirm, new_password', 'length', 'min'=>6, 'max'=>50),
			array('old_password, new_password_confirm, new_password', 'match', 'pattern'=>'#^[A-Za-z0-9]+$#u','message'=>'Используйте только латиницу и цифры.'),
			array('new_password_confirm','compare','compareAttribute'=>'new_password','message'=>'Новый пароль и подтверждение не совпадают.')
		);
	}

	/**
	 * Declares attribute labels.
	 */
	public function attributeLabels()
	{
		return array(
			'old_password'  	   => 'Пароль',
			'new_password'	 	   => 'Новый пароль',
			'new_password_confirm' => 'Подтверждение',
		);
	}
}